package com.gimi.cloud.jimi.dao.dao.userInfo;

import com.gimi.cloud.jimi.dao.dao.sys.BaseDao;
import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dto.userInfo.RdEmergencyContactDTO;
import com.gimi.cloud.jimi.entity.userInfo.RdEmergencyContact;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmergencyContactDao extends MyMapper<RdEmergencyContact>, BaseDao<RdEmergencyContact, RdEmergencyContactDTO> {

    @Select("SELECT * FROM rd_emergency_contact WHERE user_id = #{userId} AND is_delete = 0 ORDER BY ec_id DESC")
    List<RdEmergencyContact> findByUser(@Param("userId") Integer userId);

    @Select("SELECT report_effection_end FROM rd_emergency_contact WHERE user_id = #{userId}")
    RdEmergencyContactDTO getEffectionByUserId(@Param(value = "userId") Integer userId);

	@Select("SELECT * FROM rd_emergency_contact WHERE report_effection_end > NOW() AND user_id = #{userId}")
	List<RdEmergencyContactDTO> isEffection(@Param(value = "userId") Integer userId);
}
